# -*- coding: utf-8 -*- 

# Static analyzer import helpers:
if 0: 
    None
    import gluon
#    from gluon.contrib.gql import GQLDB
#    from gluon.html import A
#    from gluon.html import B
#    from gluon.html import BEAUTIFY
#    from gluon.html import BODY
#    from gluon.html import BR
#    from gluon.html import CENTER
#    from gluon.html import CLEANUP 
#    from gluon.html import CODE
#    from gluon.html import CRYPT
#    from gluon.html import DIV
#    from gluon.html import FORM
#    from gluon.html import I
#    from gluon.html import IFRAME
#    from gluon.html import IMG
#    from gluon.html import INPUT
#    from gluon.html import IS_ALPHANUMERIC
#    from gluon.html import IS_DATE
#    from gluon.html import IS_DATETIME
#    from gluon.html import IS_DATETIME_IN_RANGE
#    from gluon.html import IS_DATE_IN_RANGE
#    from gluon.html import IS_DECIMAL_IN_RANGE
#    from gluon.html import IS_EMAIL
#    from gluon.html import IS_EMPTY_OR
#    from gluon.html import IS_EQUAL_TO
#    from gluon.html import IS_EXPR
#    from gluon.html import IS_FLOAT_IN_RANGE
#    from gluon.html import IS_IMAGE
#    from gluon.html import IS_INT_IN_RANGE
#    from gluon.html import IS_IN_DB
#    from gluon.html import IS_IN_SET
#    from gluon.html import IS_IPV4
#    from gluon.html import IS_LENGTH
#    from gluon.html import IS_LIST_OF
#    from gluon.html import IS_LOWER
#    from gluon.html import IS_MATCH
#    from gluon.html import IS_NOT_EMPTY
#    from gluon.html import IS_NOT_IN_DB
#    from gluon.html import IS_NULL_OR
#    from gluon.html import IS_SLUG
#    from gluon.html import IS_STRONG 
#    from gluon.html import IS_TIME
#    from gluon.html import IS_UPLOAD_FILENAME
#    from gluon.html import IS_UPPER
#    from gluon.html import IS_URL
#    from gluon.html import LABEL
#    from gluon.html import LEGEND
#    from gluon.html import LI
#    from gluon.html import LINK
#    from gluon.html import MARKMIN
#    from gluon.html import MENU
#    from gluon.html import META
#    from gluon.html import OBJECT
#    from gluon.html import OL
#    from gluon.html import ON
#    from gluon.html import OPTGROUP
#    from gluon.html import OPTION
#    from gluon.html import P
#    from gluon.html import PRE
#    from gluon.html import SCRIPT
#    from gluon.html import SELECT
#    from gluon.html import SPAN
#    from gluon.html import TABLE
#    from gluon.html import TAG
#    from gluon.html import TBODY
#    from gluon.html import TD
#    from gluon.html import TEXTAREA
#    from gluon.html import TFOOT
#    from gluon.html import TH 
#    from gluon.html import THEAD
#    from gluon.html import TITLE
#    from gluon.html import TR
#    from gluon.html import TT
#    from gluon.html import UL
#    from gluon.html import URL
#    from gluon.html import XHTML
#    from gluon.html import XML
#    from gluon.html import embed64
#    from gluon.html import xmlescape
#    from gluon.sql import SQLDB
#    from gluon.sqlhtml import SQLFORM
#    from gluon.sql import SQLField
#    from gluon.sqlhtml import SQLTABLE
#    from gluon.html import STYLE
#    from gluon.http import redirect
    import gluon.languages.translator as T
#    from gluon.tools import  Auth
#    from gluon.tools import Service
    global auth; auth = gluon.tools.Auth()
#    global cache; cache = gluon.cache.Cache()
#    global crud; crud = gluon.tools.Crud()
    global db; db = gluon.sql.DAL()
#    import gluon.compileapp.local_import_aux as local_import
    global request; request = gluon.globals.Request()
    global response; response = gluon.globals.Response()
    global service; service = gluon.tools.Service()
    global session; session = gluon.globals.Session()
#    global DAL; DAL = gluon.dal()
#    global HTTP; HTTP = gluon.http()
#    global LOAD; LOAD = gluon.compileapp.LoadFactory()
global DEBUG
if DEBUG:
    # Relaod the module to get the changes:
    import uc_web2py_utils.i18n
    uc_web2py_utils.i18n = reload(uc_web2py_utils.i18n)
from uc_web2py_utils.i18n import always_translate

#########################################################################
## This is a samples controller
## - index is the default action of any application
## - user is required for authentication and authorization
## - download is for downloading files uploaded in the db (does streaming)
## - call exposes all registered services (none by default)
#########################################################################  

def index():
    """
    This the main page of the application.
    """
    response.flash = T('Welcome to VOA-Collect')
    response.title = T("VOA-Collect")
    response.subtitle = T("Home")
    return dict(voa_message=always_translate("voa_message", T))

def user():
    """
    exposes:
    http://..../[app]/default/user/login 
    http://..../[app]/default/user/logout
    http://..../[app]/default/user/register
    http://..../[app]/default/user/profile
    http://..../[app]/default/user/retrieve_password
    http://..../[app]/default/user/change_password
    use @auth.requires_login()
        @auth.requires_membership('group name')
        @auth.requires_permission('read','table name',record_id)
    to decorate functions that need access control
    """
    return dict(form=auth())


def download():
    """
    allows downloading of uploaded files
    http://..../[app]/default/download/[filename]
    """
    return response.download(request,db)


def call():
    """
    exposes services. for example:
    http://..../[app]/default/call/jsonrpc
    decorate with @services.jsonrpc the functions to expose
    supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv
    """
    session.forget()
    return service()


